package com.zcm.modules.cxf.entity;

import com.zcm.modules.cms.entity.Article;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * ws会话控制Entity
 * @author wangwenwei
 * @version 2018-07-28
 */

public class CxfArticleListResponse {

	private long total;
	private int pageSize;
	private int pageNo;
	private List<ArticleCxf> articles;

	public CxfArticleListResponse() {
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public long getTotal() {
		return total;
	}

	public void setTotal(long total) {
		this.total = total;
	}

	public List<ArticleCxf> getArticles() {
		return articles;
	}

	public void setArticles(List<ArticleCxf> articles) {
		this.articles = articles;
	}


	public void setArticle(List<Article> articles) {
		this.articles = new ArrayList<ArticleCxf>();
		for (Article article : articles) {
			this.articles.add(new ArticleCxf(article));
		}
	}

	static public class ArticleCxf {
		private String title;
		private String id;

		private Long pubDate;

		public ArticleCxf() {
		}

		public ArticleCxf(String title, String id, Date pubDate) {
			this.title = title;
			this.id = id;
			if(pubDate!=null){
				this.pubDate = pubDate.getTime()/1000;
			}
		}

		public ArticleCxf(Article article) {
			this.title = article.getTitle();
			this.id = article.getId();
			if(article.getCreateDate()!=null){
				this.pubDate = article.getCreateDate().getTime()/1000;
			}
		}

		public String getTitle() {
			return title;
		}

		public void setTitle(String title) {
			this.title = title;
		}

		public String getId() {
			return id;
		}

		public void setId(String id) {
			this.id = id;
		}

		public Long getPubDate() {
			return pubDate;
		}

		public void setPubDate(Long pubDate) {
			this.pubDate = pubDate;
		}
	}
}